home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / mslang / curdll / vb_demo / form1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1993-11-08  |  9.3 KB  |  222 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Custom Cursor DLL Demo"
  4.    Height          =   4680
  5.    Icon            =   FORM1.FRX:0000
  6.    Left            =   1020
  7.    LinkTopic       =   "Form1"
  8.    ScaleHeight     =   3990
  9.    ScaleWidth      =   7365
  10.    Top             =   1155
  11.    Width           =   7485
  12.    Begin CommandButton Command1 
  13.       Caption         =   "Command1"
  14.       Height          =   495
  15.       Left            =   3000
  16.       TabIndex        =   0
  17.       Top             =   2880
  18.       Width           =   1215
  19.    End
  20.    Begin Menu mnuFile 
  21.       Caption         =   "&File"
  22.       Begin Menu mnuFilePrint 
  23.          Caption         =   "&Print"
  24.       End
  25.       Begin Menu mnuFileSeperator1 
  26.          Caption         =   "-"
  27.       End
  28.       Begin Menu mnuFileExit 
  29.          Caption         =   "&Exit"
  30.          Shortcut        =   {F4}
  31.       End
  32.    End
  33.    Begin Menu mnuEdit 
  34.       Caption         =   "&Edit"
  35.       Begin Menu mnuEditCut 
  36.          Caption         =   "Cu&t"
  37.          Shortcut        =   ^X
  38.       End
  39.       Begin Menu mnuEditCopy 
  40.          Caption         =   "&Copy"
  41.          Shortcut        =   ^C
  42.       End
  43.       Begin Menu mnuEditPaste 
  44.          Caption         =   "&Paste"
  45.          Shortcut        =   ^V
  46.       End
  47.    End
  48.    Begin Menu mnuDraw 
  49.       Caption         =   "&Draw"
  50.       Begin Menu mnuDrawLine 
  51.          Caption         =   "&Line"
  52.       End
  53.       Begin Menu mnuDrawCircle 
  54.          Caption         =   "&Circle"
  55.       End
  56.       Begin Menu mnuDrawFreehand 
  57.          Caption         =   "&Freehand"
  58.       End
  59.       Begin Menu mnuDrawPaint 
  60.          Caption         =   "&Paint"
  61.       End
  62.    End
  63.    Begin Menu mnuHelp 
  64.       Caption         =   "&Help"
  65.       Begin Menu mnuHelpContext 
  66.          Caption         =   "&Context Help"
  67.          Shortcut        =   {F1}
  68.       End
  69.       Begin Menu mnuHelpSeperator1 
  70.          Caption         =   "-"
  71.       End
  72.       Begin Menu mnuHelpAbout 
  73.          Caption         =   "&About ..."
  74.       End
  75.    End
  76. ' These are the Windows API functions that need to be declared and called
  77. ' in order to use CURSOR.DLL.  Each must be entered on single line and be
  78. ' typed in exactly as shown.
  79. ' LoadLibrary:  lpLibFileName is the name of the DLL you are trying to load.
  80. '               in this case it will be CURSOR.DLL when the function is called
  81. '               in the FormLoad Procedure.
  82. ' LoadCursor:   hInstance a pointer to the CURSOR.DLL, this will be returned
  83. '               from the LoadLibrary function.  lpCursorName is the name of the
  84. '               cursor that you want to load.  A list of the cursor contained
  85. '               in CURSOR.DLL is given in the help file provided with CUSTOM
  86. '               CURSOR DLL.  This must be called once for each cursor you wish
  87. '               to load.  It can be called from any point in the program.
  88. ' SetClassWord: hWnd is the window handle returned by Windows for a Form or
  89. '               object. nIndex is a constant, this is defined below (GCW_HCURSOR)
  90. '               wNewWord will be the variable to which you saved a custom cursor
  91. '               handle.  This function needs to be called whenever you want to
  92. '               change the current cursor to a new one that has previously been
  93. '               loaded with the LoadCursor function.
  94. ' DestroyCursor:hCursor will be the variable that you saved a custom cursor in
  95. '               when you loaded it with LoadCursor.  The API function should be
  96. '               called when you exit the program so that each custom cursor that
  97. '               has been defined can be removed from system memory.
  98. '               NOTE: You should not use the DestroyCursor function unless you have
  99. '                     created the cursor with the CreateCursor API function. This
  100. '                     function is not used but was left in this demonstration in
  101. '                     case you required it for your application.
  102. ' FreeLibrary:  hLibModule will be the variable that you saved the return value
  103. '               from LoadLibrary.  This API function needs to be called when
  104. '               you exit a program that loads CURSOR.DLL with the LoadLibrary function.
  105. Declare Function LoadLibrary Lib "Kernel" (ByVal lpLibFileName As String) As Integer
  106. Declare Function LoadCursor Lib "User" (ByVal hInstance As Integer, ByVal lpCursorName As Any) As Integer
  107. Declare Function SetClassWord Lib "User" (ByVal hWnd As Integer, ByVal nIndex As Integer, ByVal wNewWord As Integer) As Integer
  108. Declare Function DestroyCursor Lib "User" (ByVal hCursor As Integer) As Integer
  109. Declare Sub FreeLibrary Lib "Kernel" (ByVal hLibModule As Integer)
  110. ' Constant and variable declarations
  111. Const GCW_HCURSOR = (-12)
  112. Dim CurCustom1
  113. Dim CurCustom2
  114. Dim CurCustom3
  115. Dim CurCustom4
  116. Dim CurCustom5
  117. Dim CurCustom6
  118. Dim CurCustom7
  119. Dim CurCustom8
  120. Dim CurCustom9
  121. Dim CurCustom10
  122. Dim SysCursor
  123. Dim DLLInstance
  124. Dim CommandCursor
  125. Sub Form_Load ()
  126. ' Written by:  Robert B. Cooper
  127. '              ELECTRON Software
  128. '              P.O. Box 309
  129. '              Mt. Storm, WV. 26739
  130. '              CompuServe ID#: 73244,3472
  131. '              America OnLine: ELECTRON
  132. ' The Visual Basic files for the Custom Cursor DLL Demonstration were
  133. ' written with VB version 2.0.
  134. ' You have a royalty-free right to use, modify, reproduce and distribute the
  135. ' Visual Basic sample filesprovided that you agree that ELECTRON SOFTWARE has
  136. ' no warranty obligations or liability for any Sample Application Files which
  137. ' are modified.
  138.     ' Call the LoadLibrary Function to load the CURSOR DLL into memory.
  139.     ' The returned handle is then stored in DLLInstance.
  140.     DLLInstance = LoadLibrary("CURSOR.DLL")
  141.     ' The next 10 lines load each cursor to be used.
  142.     ' The returned handle is stored in the variable CurCustom(1 - 10)
  143.     CurCustom1 = LoadCursor(DLLInstance, "POINTER_NW")
  144.     CurCustom2 = LoadCursor(DLLInstance, "PRINTER")
  145.     CurCustom3 = LoadCursor(DLLInstance, "SCISSORS_NW")
  146.     CurCustom4 = LoadCursor(DLLInstance, "HAND_DRAG_1")
  147.     CurCustom5 = LoadCursor(DLLInstance, "PIN_NW")
  148.     CurCustom6 = LoadCursor(DLLInstance, "DRAW_LINE")
  149.     CurCustom7 = LoadCursor(DLLInstance, "DRAW_CIRCLE")
  150.     CurCustom8 = LoadCursor(DLLInstance, "DRAW_FREEHAND")
  151.     CurCustom9 = LoadCursor(DLLInstance, "PAINT_BRUSH_SW")
  152.     CurCustom10 = LoadCursor(DLLInstance, "CONTEXT_HELP")
  153.     ' The SetClassWord Function needs to be called to change the presently
  154.     ' loaded cursor to a new cursor.
  155.     ' The 0-Default cursor MUST BE set on each Form and Control that you want
  156.     ' to use a custom cursor.
  157.     SysCursor = SetClassWord(Form1.hWnd, GCW_HCURSOR, CurCustom1)
  158.     ' This next line ensures that the POINTER_NW Custom Cursor is always
  159.     ' shown when the mouse is over the Command Button.
  160.     CommandCursor = SetClassWord(Command1.hWnd, GCW_HCURSOR, CurCustom1)
  161. End Sub
  162. Sub Form_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
  163.     ' This section restores the POINTER_NW Custom Cusor when the right mouse
  164.     ' button is pressed and released.
  165.     If Button = 2 Then
  166.         SysCursor = SetClassWord(Form1.hWnd, GCW_HCURSOR, CurCustom1)
  167.     End If
  168. End Sub
  169. Sub Form_Unload (Cancel As Integer)
  170.     ' Call the FreeLibrary API function to remove CURSOR.DLL from memory.
  171.     Call FreeLibrary(DLLInstance)
  172. End Sub
  173. Sub mnuDrawCircle_Click ()
  174.     ' Changes the Cursor to the DRAW_CIRCLE Custom Cursor.
  175.     SysCursor = SetClassWord(Form1.hWnd, GCW_HCURSOR, CurCustom7)
  176. End Sub
  177. Sub mnuDrawFreehand_Click ()
  178.     ' Changes the Cursor to the DRAW_FREEHAND Custom Cursor.
  179.     SysCursor = SetClassWord(Form1.hWnd, GCW_HCURSOR, CurCustom8)
  180. End Sub
  181. Sub mnuDrawLine_Click ()
  182.     ' Changes the Cursor to the DRAW_LINE Custom Cursor.
  183.     SysCursor = SetClassWord(Form1.hWnd, GCW_HCURSOR, CurCustom6)
  184. End Sub
  185. Sub mnuDrawPaint_Click ()
  186.     ' Changes the Cursor to the DRAW_PAINT Custom Cursor.
  187.     SysCursor = SetClassWord(Form1.hWnd, GCW_HCURSOR, CurCustom9)
  188. End Sub
  189. Sub mnuEditCopy_Click ()
  190.     ' Changes the Cursor to the HAND_DRAG_1 Custom Cursor.
  191.     SysCursor = SetClassWord(Form1.hWnd, GCW_HCURSOR, CurCustom4)
  192. End Sub
  193. Sub mnuEditCut_Click ()
  194.     ' Changes the Cursor to the SCISSORS Custom Cursor.
  195.     SysCursor = SetClassWord(Form1.hWnd, GCW_HCURSOR, CurCustom3)
  196. End Sub
  197. Sub mnuEditPaste_Click ()
  198.     ' Changes the Cursor to the PIN_NW Custom Cursor.
  199.     SysCursor = SetClassWord(Form1.hWnd, GCW_HCURSOR, CurCustom5)
  200. End Sub
  201. Sub mnuFileExit_Click ()
  202.     ' Unloads Form1, executes the code located in the FORM.UNLOAD procedure
  203.     ' and exits the program.
  204.     Unload Form1
  205.     End
  206. End Sub
  207. Sub mnuFilePrint_Click ()
  208.     ' Changes the Cursor to the PRINTER Custom Cursor.
  209.     SysCursor = SetClassWord(Form1.hWnd, GCW_HCURSOR, CurCustom2)
  210. End Sub
  211. Sub mnuHelpAbout_Click ()
  212.     ' The About Dialog Box has its cursor set to the default arrow cursor
  213.     ' provided by the windows enviroment.  This is accomplished by setting
  214.     ' the MousePointer Property to 1-Arrow.  Remember to be able to use a
  215.     ' custom cursor you must set the MousePointer property to 0-default.
  216.     ABOUT.Show 1
  217. End Sub
  218. Sub mnuHelpContext_Click ()
  219.     ' Changes the Cursor to the HELP_CONTEXT Custom Cursor.
  220.     SysCursor = SetClassWord(Form1.hWnd, GCW_HCURSOR, CurCustom10)
  221. End Sub
  222.